from fastapi import FastAPI,Body,Request
from pika.pika_proxy import PikaBaseRequest
from  loguru import  logger
app = FastAPI()
from conf import Config as myconf

@app.get("/")
def read_root():
    return {"Hello": "World"}

@app.post("/pika_base")
async def pika_base(request: PikaBaseRequest = Body(...)):
    """
    示例 curl 请求：
    curl --request POST \
      --url http://localhost:18028/qry_hc_detail \
      --header 'content-type: application/json' \
      --data '{"orgid": 85810, "medcasno": "10486319", "feedetl_sns": ["43074259","43074225"],"adm_date":"2024-05-24 15:15","dscg_date":"2024-07-06 08:44","med_list_code15":"003107010220000","med_list_name":"心电监"}'
    """
    logger.info(f"pika_base : request = {request} ")
    mgr=QryDetailMgrFactory().get_mgr()
    return mgr.yz_main(request)


if __name__ == "__main__":
    import uvicorn
    api_port = int(myconf.api_port if myconf.api_port else 18029)
    uvicorn.run(app, host="0.0.0.0", port=api_port)